﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MESCodeFile;

namespace mes_tublay
{
    partial class frmMain
    {
        //Event Handlers
        void MenuHandlers()
        {
            mnuCloseAll.Click += new EventHandler(mnuCloseAll_Click);

            //System Menus
            mnuAbout.Click += new EventHandler(mnuAbout_Click);
            mnuExit.Click += new EventHandler(mnuExit_Click);
            mnuSettings.Click += new EventHandler(mnuSettings_Click);
            
            //Other Department for Clearance Purposes
            mnuDocumentCheckList.Click += new EventHandler(mnuDocumentCheckList_Click);

            //Mayor's Office Menus
            mnuBusinessPermit.Click += new EventHandler(mnuBusinessPermit_Click);
            mnuMayorsApprovalForm.Click += new EventHandler(delegate 
                {
                    frmMayorApproval frm = new frmMayorApproval();
                    frm.Initialize("Mayor Approval Form");
                    sldMain.AddItem(frm.PanelForm, "Mayor Approval Form");
                });
            mnuSpecialDocumentsChecklist.Click += new EventHandler(delegate
                {
                    frmDocumentsCheckList frm = new frmDocumentsCheckList("for Other Offices");
                    frm.Initialize("Special Documents Checklist");
                    sldMain.AddItem(frm.PanelForm, "Special Documents Checklist");
                });
            //Treasury Office Menus
            mnuTreasuryeBPLS.Click+=new EventHandler(mnuTreasuryeBPLS_Click);
            mnuschedofvalues.Click += new EventHandler(delegate
            {
                frmScheduleofValues frm = new frmScheduleofValues();
                frm.Initialize("Schedule of Values");
                sldMain.AddItem(frm.PanelForm, "Schedule of Values");
            });
            mnuPayment.Click += new EventHandler(delegate
                {
                    frmTreasuryPayment frm = new frmTreasuryPayment();
                    frm.Initialize("Payment Form");
                    sldMain.AddItem(frm.PanelForm, "Payment Form");
                });
           
            mnuaddbusinesstype.Click += new EventHandler(delegate
                {
                    frmLineofBusiness frm = new frmLineofBusiness();
                    frm.ShowDialog();
                });
            
            //Assessor's Office Menus
            mnuRPFAAS.Click += new EventHandler(delegate
            {
                frmRPFieldAssessment frm = new frmRPFieldAssessment();
                frm.Initialize("Real Property Field Assessment");
                sldMain.AddItem(frm.PanelForm, "Real Property Field Assessment");
            });
            
           /* mnuRPA_Machinery.Click += new EventHandler(delegate
            {
                frmRPFieldAssessmentMachinery frm = new frmRPFieldAssessmentMachinery();
                frm.Initialize("Real Property Field Assessment - Machinery");
                sldMain.AddItem(frm.PanelForm, "Real Property Field Assessment - Machinery");
            });  */
            
            mnuTaxDeclaration.Click += new EventHandler(delegate
            {
                frmTaxDecRealProperty frm = new frmTaxDecRealProperty();
                frm.Initialize("Tax Declaration of Real Property");
                sldMain.AddItem(frm.PanelForm, "Tax Declaration of Real Property");
            });
            
            mnuAssessmentRoll.Click += new EventHandler(delegate
            {
                frmAssessmentRoll frm = new frmAssessmentRoll();
                frm.Initialize("Assessment Roll");
                sldMain.AddItem(frm.PanelForm, "Assessment Roll");
            });

            //Property Custodian Module
            mnuInventorySystem.Click += new EventHandler(delegate
            {
                bool found = false;
                for (int i = 0; i < sldMain.ItemList.Length; i++)
                {
                    if (sldMain.ItemList[i].Equals("Inventory System")) found = true;
                }
                if (found) return;
                frmInventorySystem frm = new frmInventorySystem();
                frm.Initialize("Inventory System");
                sldMain.AddItem(frm.PanelForm, "Inventory System");

            });
            //Admin Menus
            mnuLookupManager.Click += new EventHandler(mnuLookupManager_Click);
            mnuUserManagement.Click += new EventHandler(mnuUserManagement_Click);
            mnuLogin.Click += new EventHandler(mnuLogin_Click);
            mnuBPLSFeesAndChargesManager.Click += new EventHandler(delegate 
            {
                frmBPLSFeesAndChargesManager frm = new frmBPLSFeesAndChargesManager();
                frm.Initialize("BPLS Fees and Charges Manager");
                sldMain.AddItem(frm.PanelForm, "BPLS Fees and Charges Manager");
            });
            mnuProfile.Click += new EventHandler(mnuProfile_Click);
            mnuTeamSampler.Click += new EventHandler(delegate
            {
                frmTeamSampler frm = new frmTeamSampler();
                frm.Initialize("Team Sampler");
                sldMain.AddItem(frm.PanelForm, "Team Sampler");
            });
        }

       //Event Callbacks
        void mnuDocumentCheckList_Click(object sender, EventArgs e)
        {
            string department = "";
            switch(documentChecklist.responsibleOffice)
            {
                case "MUNICIPAL HEALTH OFFICE":
                case "MHO": department = "MUNICIPAL HEALTH OFFICE"; break;
                case "MUNICIPAL ENGINEERING OFFICE":
                case "MEO": department = "MUNICIPAL ENGINEERING OFFICE"; break;
                case "FIRE_DEPARTMENT":
                case "FIRE DEPARTMENT": department = "FIRE DEPARTMENT"; break;
                case "MUNICIPAL PLANNING AND DEVELOPMENT OFFICE":
                case "MPDO": department = "MUNICIPAL PLANNING AND DEVELOPMENT OFFICE"; break;
                case "MASSO": department = "MASSO"; break;
                case "PNP_TUBLAY": department = "PNP_TUBLAY"; break;
            }
            frmDocumentsCheckList frm = new frmDocumentsCheckList(department);
            frm.Initialize("Document's Checklist Manager");
            sldMain.AddItem(frm.PanelForm, "Document's Checklist Manager");
        }

        void mnuProfile_Click(object sender, EventArgs e)
        {
            frmMyProfile frm = new frmMyProfile();
            frm.ShowDialog();
        }
        void mnuLogin_Click(object sender, EventArgs e)
        {
            if (!Common.LOGGED)
            {
                frmLogin frm = new frmLogin();
                frm.ShowDialog();
            }
            else
            {
                if (Confirm.Question("Logout Confirm", "Do you wish to continue?") == System.Windows.Forms.DialogResult.No) return;
                if (sldMain.ItemCount > 0) sldMain.Controls.Clear();

                CurrentUser.IMG.Dispose();
                CurrentUser.IMG = new Bitmap(48, 48);
                CurrentUser.UID = "";
                CurrentUser.PRIV = new object[0];
                CurrentUser.PWD = "";
                Common.LOGGED = false;
                liveNotify.NotifyCloseArea();
                liveNotify.NotifyOpenText = "Close Notification";
                liveNotify.NotifyCloseText = "Notification not ready...";

                mnuLogin.Text = "Login";
                DisableMenu();
            }
        }
        void mnuUserManagement_Click(object sender, EventArgs e)
        {
            bool found = false;
            for (int i = 0; i < sldMain.ItemList.Length; i++)
            {
                if (sldMain.ItemList[i].Equals("User Management")) found = true;
            }
            if (found) return;
            frmUserManager frm = new frmUserManager();
            frm.Initialize("User Management");
            sldMain.AddItem(frm.PanelForm, "User Management");
        }
        void mnuLookupManager_Click(object sender, EventArgs e)
        {
            bool found = false;
            for (int i = 0; i < sldMain.ItemList.Length; i++)
            {
                if (sldMain.ItemList[i].Equals("Lookup Manager")) found = true;
            }
            if (found) return;
            frmLookUpManager frm = new frmLookUpManager();
            frm.Initialize("Lookup Manager");
            sldMain.AddItem(frm.PanelForm, "Lookup Manager");
        }
        void mnuTreasuryeBPLS_Click(object sender, EventArgs e)
        {
            frmeBPLSsearch frm = new frmeBPLSsearch();
            frm.Initialize("Treasury eBPLS");
            sldMain.AddItem(frm.PanelForm, "Treasury eBPLS");
        }
        void mnuBusinessPermit_Click(object sender, EventArgs e)
        {
            frmBusinessPermit frm = new frmBusinessPermit();
            frm.Initialize("Business Permit Manager");
            sldMain.AddItem(frm.PanelForm, "Business Permit Manager");
        }
        void mnuSettings_Click(object sender, EventArgs e)
        {
            bool found = false;
            for (int i = 0; i < sldMain.ItemList.Length; i++)
            {
                if (sldMain.ItemList[i].Equals("Settings")) found = true;
            }
            if (!found)
            {
                frmConfig frm = new frmConfig();
                frm.Initialize("Settings");
                sldMain.AddItem(frm.PanelForm, "Settings");
            }
        }
        void mnuAbout_Click(object sender, EventArgs e)
        {
            frmAboutThis frm = new frmAboutThis();
            frm.Initialize("About Management Execution System");
            sldMain.AddItem(frm.PanelForm, "About Management Execution System");
        }
    }
}